﻿using System.Web;

namespace TrafficArchives.Utilities
{
    public class LoginUser
    {
        private LoginUser()
        {
        }

        public bool IsSupperAdmin { get; set; }

        public bool IsLogined { get; set; }

        public string UserId { get; set; }

        public string UserCode { get; set; }

        public string UserName { get; set; }

        public string RoleId { get; set; }

        public string RoleName { get; set; }

        public string DepartmentId { get; set; }

        public string DepartmentName { get; set; }

        public string MenuString { get; set; }

        public static LoginUser Current
        {
            get
            {
                var current = (LoginUser)HttpContext.Current.Session.Contents[SessionKey];
                if (current == null)
                {
                    current = new LoginUser();
                    HttpContext.Current.Session.Contents[SessionKey] = current;
                }
                return current;
            }
        }

        /// <summary>
        /// 注销。
        /// </summary>
        public void SignOut()
        {
            HttpContext.Current.Session.Contents.Remove(SessionKey);
        }

        public static string SessionKey
        {
            get { return "LoginUser"; }
        }
    }
}